﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CmpEdu
{
    /// <summary>
    /// 定义基类Cuboid（长方体）
    /// </summary>
    public class Cuboid
    {
        protected double length;
        private double width;
        private double height;

        /// <summary>
        /// 定义class Cuboid（长方体）的构造函数
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public Cuboid(double x, double y, double z)
        {
            length = x;
            width = y;
            height = z;
        }

        /// <summary>
        /// 定义方法CalcCubage求体积
        /// </summary>
        /// <returns></returns>
        public virtual double CalcCubage()
        {
            return length * width * height;
        }
    }

    /// <summary>
    /// 定义派生类class Cube（正方体）
    /// </summary>
    public class Cube : Cuboid
    {
        public Cube(double x):base(x, 0, 0) { }         //定义派生类的构造函数
        public override double CalcCubage()
        {
            return Math.Pow(length, 3);
        }
    }
}
